package demo7;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Person {
    private String name;

    public Person(){
        System.out.println("1:Person的无参构造方法执行了...");
    }

    public String getName() {
        return name;
    }

    @Value("张三")
    public void setName(String name) {
        System.out.println("2:Person的name属性初始化了...");
        this.name = name;
    }

    @PostConstruct
    public void init(){
        System.out.println("3:Person对象被容器初始化完毕了...");
    }

    public void play() {
        System.out.println("4:Person对象的play方法被调用了...");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("5:Person对象被容器销毁之前...");
    }
}
